package com.jc.order.dto;

public class FieldChangeDTO {

    private  String fieldName;
    private  String fieldDescription;
    private  Object oldValue;
    private  Object newValue;
    public FieldChangeDTO(){

    }
    public FieldChangeDTO(String fieldName, String fieldDescription,
                       Object oldValue, Object newValue) {
        this.fieldName = fieldName;
        this.fieldDescription = fieldDescription;
        this.oldValue = oldValue;
        this.newValue = newValue;
    }

    // Getter方法
    public String getFieldName() { return fieldName; }
    public String getFieldDescription() { return fieldDescription; }
    public Object getOldValue() { return oldValue; }
    public Object getNewValue() { return newValue; }

    @Override
    public String toString() {
        return String.format("%s(%s): [旧值: %s] → [新值: %s]",
                fieldDescription, fieldName,
                formatValue(oldValue),
                formatValue(newValue));
    }

    private String formatValue(Object value) {
        if (value == null) return "null";
        return value.toString();
    }

}
